package tron.oauth.config;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 获取用户，获取资源权限 认证的核心服务类
 */
@Service
public class RootService {

    protected SystemUser getUserByUserName() {
        System.out.println("====RootService=========getUserByUserName============");
        final SystemUser systemUser = new SystemUser();
        systemUser.setPassword(new BCryptPasswordEncoder().encode("123"));
        systemUser.setUsername("tron");
        systemUser.setAge(100);
        systemUser.setId("001");
        return systemUser;
    }

    public SystemUser getUserByToken() {
        System.out.println("====RootService=========getUserByToken============");
        final SystemUser systemUser = new SystemUser();
        systemUser.setPassword(new BCryptPasswordEncoder().encode("123"));
        systemUser.setUsername("tron");
        systemUser.setAge(100);
        systemUser.setId("001");
        return systemUser;
    }

    protected List<String> getRoleByUser() {
        System.out.println("====RootService=========getRoleByUser============");
        return Arrays.asList("A", "B");
    }

    protected List<String> getRoleByUrl() {
        System.out.println("====RootService=========getRoleByUrl============");
        return Arrays.asList("A", "B");
    }

    protected void loginLog() {
        System.out.println("记录登录日志");
    }
}
